// app.js
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    userInfo: null,
    
  },

  showModal(e){
    wx.showModal({
      title: e.title || '系统提示',
      content: typeof e=='string' ? e : e.content,
      showCancel: e.showCancel || false,
      confirmText: e.confirmText || '确定',
      success: (res) => {
        if(!e.success) return;
        let confirm;
        if (res.cancel) confirm=false;
        else if (res.confirm) confirm=true;
        e.success({confirm});
      }
    })
  },
  showModal1(e){
    wx.showModal({
      title: e.title || '系统提示',
      content: typeof e=='string' ? e : e.content,
      showCancel: e.showCancel || false,
      confirmText: e.confirmText || '确认',
      success: (res) => {
        if(!e.success) return;
        let confirm;
        if (res.cancel) confirm=false;
        else if (res.confirm) confirm=true;
        e.success({confirm});
      }
    })
  },
  showToast(e){
    wx.showToast({
      title: typeof e=='object' ? e.title : e,
      icon:e.icon || 'none'
    })
  }
})
